<script setup lang="ts">
defineOptions({
  name: 'Table'
});
const tableData = [
  {
    date: '2016-05-03',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036'
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036'
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036'
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036'
  },
  {
    date: '2016-05-08',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036'
  },
  {
    date: '2016-05-06',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036'
  },
  {
    date: '2016-05-07',
    name: 'Tom',
    state: 'California',
    city: 'Los Angeles',
    address: 'No. 189, Grove St, Los Angeles',
    zip: 'CA 90036'
  }
];
const onClick = () => {
  console.log('click');
};
</script>

<template>
  <div class="p">
    <el-card shadow="never" class="mb">
      <template #header>
        <div class="card-header">
          <span>基础表格</span>
        </div>
      </template>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="date" label="Date" width="150" />
        <el-table-column prop="name" label="Name" width="120" />
        <el-table-column prop="state" label="State" width="120" />
        <el-table-column prop="city" label="City" />
      </el-table>
      <div class="mt flex justify-end">
        <el-pagination background layout="prev, pager, next" :total="1" />
      </div>
    </el-card>
    <el-card shadow="never" class="mb">
      <template #header>
        <div class="card-header">
          <span>边框表格</span>
        </div>
      </template>
      <el-table :data="tableData" stripe style="width: 100%" border>
        <el-table-column prop="date" label="Date" width="150" />
        <el-table-column prop="name" label="Name" width="120" />
        <el-table-column prop="state" label="State" width="120" />
        <el-table-column prop="city" label="City" width="320" />
        <el-table-column prop="address" label="Address" />
      </el-table>
      <div class="mt flex justify-end">
        <el-pagination background layout="prev, pager, next" :total="1" />
      </div>
    </el-card>
    <el-card shadow="never" class="mb">
      <template #header>
        <div class="card-header">
          <span>综合表格</span>
        </div>
      </template>
      <el-table :data="tableData" stripe style="width: 100%" border>
        <el-table-column type="selection" width="55" />
        <el-table-column type="index" />
        <el-table-column prop="date" label="Date" width="150" />
        <el-table-column prop="name" label="Name" width="120" sortable />
        <el-table-column prop="state" label="State" width="120">
          <template #default="scope">
            <el-popover
              effect="light"
              trigger="hover"
              placement="top"
              width="auto"
            >
              <template #default>
                <div>state: {{ scope.row.state }}</div>
                <div>address: {{ scope.row.address }}</div>
              </template>
              <template #reference>
                <el-tag>{{ scope.row.state }}</el-tag>
              </template>
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column prop="city" label="City" width="320" />
        <el-table-column prop="address" label="Address" width="600" />
        <el-table-column prop="zip" label="Zip" width="120" />
        <el-table-column fixed="right" label="Operations" width="120">
          <template #default>
            <el-button link type="primary" size="small" @click="onClick"
              >Detail</el-button
            >
            <el-button link type="primary" size="small">Edit</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="mt flex justify-end">
        <el-pagination background layout="prev, pager, next" :total="1" />
      </div>
    </el-card>
  </div>
</template>
